package com.power.taskcenter.service.impl;

import cn.hutool.log.Log;
import cn.hutool.log.LogFactory;

import com.power.taskcenter.entity.DynamicTaskLogs;
import com.power.taskcenter.mapper.SchoolJobsExecuteMapper;
import com.power.taskcenter.service.JobsExecuteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

@Service
public class JobsExecuteServiceImpl implements JobsExecuteService {

    private static final Log log = LogFactory.get();

    @Autowired
    private SchoolJobsExecuteMapper jobsExecuteMapper;

    @Override
    public void jobWarning() {
          jobsExecuteMapper.executWarning(null);
//        Integer rid = jobExecuteLogDAO.getRid();
//        jobExecuteLogDAO.saveJobLog(rid,"预警加工","P_SCHOOLMONITOR_WARNING2015.WARNING_STATISTICS(NULL)","");
//        jobsExecuteDAO.jobCallPro("P_SCHOOLMONITOR_WARNING2015.WARNING_STATISTICS(NULL)");
//        jobExecuteLogDAO.updateJobLog(rid,"加工结束");
//        log.info(DateUtil.format(new Date(),"yyyyMMddHHmmssSSS")+"jobWarning");
    }

    @Override
    public void jobHome() throws Exception{

//        Integer rid = jobExecuteLogDAO.getRid();
//        jobExecuteLogDAO.saveJobLog(rid,"首页数据和基础数据","p_schoolmonitor_default.process_base_default(null)","");
//        List lst = jobsExecuteMapper.queryLogs(new DynamicTaskLogs());
//        jobsExecuteMapper.executProcess();
//        jobsExecuteMapper.executWarning(null);
         jobsExecuteMapper.executHome(null);
//        jobExecuteLogDAO.updateJobLog(rid,"加工结束");
//        log.info(DateUtil.format(new Date(),"yyyyMMddHHmmssSSS")+" jobHome  ");
    }

    @Override
    public void jobProcess() {
        jobsExecuteMapper.executProcess(null);
//        Integer rid = jobExecuteLogDAO.getRid();
//        jobExecuteLogDAO.saveJobLog(rid," 教育体检体检基本表组织","P_SCHOOLMONITOR_STATISTICS2012.REPORT_PROCESS_class_medical('')","");
//        jobsExecuteDAO.jobCallPro("P_SCHOOLMONITOR_STATISTICS2012.REPORT_PROCESS_class_medical('')");
//        jobExecuteLogDAO.updateJobLog(rid,"加工结束");
//        log.info(DateUtil.format(new Date(),"yyyyMMddHHmmssSSS") +" jobProcess  ");
    }

    @Override
//    @Async("publicTaskExecutor")
    public void jobProcess1() {
        Map<String,Object> params=new LinkedHashMap<String,Object>();
        params.put("school_year", null);
        params.put("school_month", null);

        jobsExecuteMapper.executProcess1(params);
//        Integer rid = jobExecuteLogDAO.getRid();
//        jobExecuteLogDAO.saveJobLog(rid," 缺课相关报表1","P_SCHOOLMONITOR_STATISTICS2012.REPORT_PROCESS_DATA(NULL,NULL)","");
//        jobsExecuteDAO.jobCallPro("P_SCHOOLMONITOR_STATISTICS2012.REPORT_PROCESS_DATA(NULL,NULL)");
//        jobExecuteLogDAO.updateJobLog(rid,"加工结束");
//        log.info(DateUtil.format(new Date(),"yyyyMMddHHmmssSSS")+" jobProcess1  ");
    }

    @Override
//    @Async("publicTaskExecutor")
    public void jobProcess2() {
        jobsExecuteMapper.executProcess2(null);
//        Integer rid = jobExecuteLogDAO.getRid();
//        jobExecuteLogDAO.saveJobLog(rid," 缺课相关报表2","P_SCHOOLMONITOR_STATISTICS2015.REPORT_PROCESS_DATA(NULL)","");
//        jobsExecuteDAO.jobCallPro("P_SCHOOLMONITOR_STATISTICS2015.REPORT_PROCESS_DATA(NULL)");
//        jobExecuteLogDAO.updateJobLog(rid,"加工结束");
//        log.info(DateUtil.format(new Date(),"yyyyMMddHHmmssSSS")+"jobProcess2  " );
    }

    @Override
//    @Async("publicTaskExecutor")
    public void jobSepProcess() {
        jobsExecuteMapper.executSepProcess();
//        Integer rid = jobExecuteLogDAO.getRid();
//        jobExecuteLogDAO.saveJobLog(rid," 缺课上报时间组织等","P_SCHOOLMONITOR_SEPTEMBER.sep_process","");
//        jobsExecuteDAO.jobCallPro("P_SCHOOLMONITOR_SEPTEMBER.sep_process()");
//        jobExecuteLogDAO.updateJobLog(rid,"加工结束");
//        log.info(DateUtil.format(new Date(),"yyyyMMddHHmmssSSS")+" jobSepProcess  ");
    }

    @Override
//    @Async("publicTaskExecutor")
    public void jobStudentNumProcess() {
        jobsExecuteMapper.executStudentNumProcess();
//        Integer rid = jobExecuteLogDAO.getRid();
//        jobExecuteLogDAO.saveJobLog(rid," 学校学生和班级人数计算","P_data_studentnum.data_process","");
//        jobsExecuteDAO.jobCallPro("P_data_studentnum.data_process()");
//        jobExecuteLogDAO.updateJobLog(rid,"加工结束");
//        log.info( DateUtil.format(new Date(),"yyyyMMddHHmmssSSS")+" jobStudentNumProcess  ");
    }

    @Override
//    @Async("publicTaskExecutor")
    public void jobLnjuryProcess() {
        jobsExecuteMapper.executLnjuryProcess();
//        Integer rid = jobExecuteLogDAO.getRid();
//        jobExecuteLogDAO.saveJobLog(rid," 伤害相关报表","P_SCHOOLMONITOR_STATISTICS6.exec_lnjury_proc_schoolyear","");
//        jobsExecuteDAO.jobCallPro("P_SCHOOLMONITOR_STATISTICS6.exec_lnjury_proc_schoolyear()");
//        jobExecuteLogDAO.updateJobLog(rid,"加工结束");
//        log.info(DateUtil.format(new Date(),"yyyyMMddHHmmssSSS")+" jobLnjuryProcess  ");
    }

    @Override
    public List<Map<String,Object>> queryCurDate() {
           return jobsExecuteMapper.queryCurDate();
    }


}


